package com.ruoyi.web.controller.shop.mapper;

import com.ruoyi.common.core.dao.BaseMapper;
import com.ruoyi.common.entity.DO.marketing.CouponDO;
import com.ruoyi.common.entity.DO.member.MemberCouponDO;
import com.ruoyi.common.entity.DO.product.ShopProductCouponLinkDO;
import com.ruoyi.common.entity.VO.CouponSearchVO;
import com.ruoyi.common.entity.VO.CouponVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface IBackShopProductCouponLinkMapper extends BaseMapper<ShopProductCouponLinkDO> {

    @Delete("DELETE FROM shop_product_coupon_link WHERE shop_id=#{shopId} and product_id=#{productId} and module_id=2")
    int clear(@Param("shopId") Long shopId, @Param("productId") Long productId);

    @Delete("DELETE FROM shop_product_coupon_link WHERE shop_id=#{shopId} and coupon_id=#{couponId} and module_id=1")
    int clearByCouponId(@Param("shopId") Long shopId, @Param("couponId") Long couponId);

    @Select("SELECT coupon_id from shop_product_coupon_link WHERE shop_id=#{shopId} and product_id=#{productId} and module_id=2")
    List<Long> searchIdList(@Param("shopId") Long shopId, @Param("productId") Long productId);

    @Select("SELECT product_id from shop_product_coupon_link WHERE shop_id=#{shopId} and coupon_id=#{couponId} and module_id=1")
    List<Long> searchIdListByCouponId(@Param("shopId") Long shopId, @Param("couponId") Long couponId);
}
